﻿Imports System.Data.Entity.Validation
Imports System
Imports System.Security.Claims
Imports System.Web.UI
Imports System.Data.OleDb
Imports System.IO
Imports System.Collections.Generic

Public Class AddMoneyData
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub
    Protected Sub Button3_Click(sender As Object, e As EventArgs)

        Try
            If fl6.HasFile Then

                Dim fileName As String = Path.GetFileName(fl6.PostedFile.FileName)
                fl6.PostedFile.SaveAs(Server.MapPath("~/Upload/") + fileName)



                Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("ConnectionString004").ConnectionString)
                Dim SqlString As String = "Insert into sms_moneydata(moneytype_fkid,moneysubtype_fkid, Company_Name, Location,Stars,Description,Contact_Details,Picture,companyurl) Values (@f1,@f2,@f3,@f4,@f5,@f6,@f7,@f8,@f9)"

                Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)

                cmd.CommandType = CommandType.Text
                cmd.Parameters.AddWithValue("@f1", ddl_moneytype.SelectedValue)
                cmd.Parameters.AddWithValue("@f2", ddl_submoney.SelectedValue)
                cmd.Parameters.AddWithValue("@f3", company_name.Text)
                cmd.Parameters.AddWithValue("@f4", location.Text)

                If RadioButton1.Checked = True Then
                    cmd.Parameters.AddWithValue("@f5", 1)
                ElseIf RadioButton2.Checked = True Then
                    cmd.Parameters.AddWithValue("@f5", 2)
                ElseIf RadioButton3.Checked = True Then
                    cmd.Parameters.AddWithValue("@f5", 3)
                ElseIf RadioButton4.Checked = True Then
                    cmd.Parameters.AddWithValue("@f5", 4)
                ElseIf RadioButton5.Checked = True Then
                    cmd.Parameters.AddWithValue("@f5", 5)
                Else
                    lblError.Text = "Please select star"
                    Return
                End If

                cmd.Parameters.AddWithValue("@f6", txt_desc.Text)
                cmd.Parameters.AddWithValue("@f7", contact_details.Text)
                cmd.Parameters.AddWithValue("@f8", fileName)
                cmd.Parameters.AddWithValue("@f9", company_url.Text)

                oleDbConn.Open()
                cmd.ExecuteNonQuery()

                ScriptManager.RegisterClientScriptBlock( _
            Me, _
            GetType(Page), _
            "script", _
            "returnempcode();", _
            True)



            End If

        Catch ex As DbEntityValidationException

        End Try


    End Sub

  

    Protected Sub contact_details_TextChanged(sender As Object, e As EventArgs) Handles contact_details.TextChanged

    End Sub
End Class